using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "CountryFlags", menuName = "ScriptableObjects/CountryFlags", order = 1)]
public class CountryFlags : ScriptableObject
{
	public Sprite defaultSprite;

	public Sprite[] spriteList;

	public Dictionary<string, Sprite> dict = new Dictionary<string, Sprite>();

	public Sprite GetSprite(string countryCode)
	{
		if (dict.Count == 0)
		{
			Sprite[] array = spriteList;
			foreach (Sprite sprite in array)
			{
				dict.Add(sprite.name, sprite);
			}
		}
		if (!string.IsNullOrEmpty(countryCode))
		{
			string key = countryCode.ToLower();
			if (dict.ContainsKey(key))
			{
				return dict[key];
			}
		}
		return defaultSprite;
	}
}
